//
//  Dog.m
//  Msg
//
//  Created by 蜂巢网络科技 on 2017/7/10.
//  Copyright © 2017年 fengchao. All rights reserved.
//

#import "Dog.h"
#import "NSObject+Extension.h"

#define RQPersonalPath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0] stringByAppendingPathComponent:@"personal.plist"]

@implementation Dog

// 设置不需要归解档的属性
- (NSArray *)ignoredNames {
    return @[@"_aaa",@"_bbb",@"_ccc"];
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];
    if (self) {
        [self decode:aDecoder];
    }
    return self;
}


// 归档调用方法
- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [self encode:aCoder];
}

// 保存个人信息的数据归档
+ (void)saveDog:(Dog *)dog
{
    [NSKeyedArchiver archiveRootObject:dog toFile:RQPersonalPath];
}

+ (Dog *)readDog
{
    Dog *dog = [NSKeyedUnarchiver unarchiveObjectWithFile:RQPersonalPath];
    return dog;
}

@end
